%module censorwords

/** signed32 Convert from Python --> C */
%typemap(in) int32_t {
    if (PyInt_Check($input)) {
        $1 = (int32_t) PyInt_AsLong($input);
    } else if (PyLong_Check($input)) {
        $1 = (int32_t) PyLong_AsLong($input);
    } else {
       SWIG_exception_fail(SWIG_ValueError, "unknown integer type");
    }
}
 
/** signed32 Convert from C --> Python */
%typemap(out) int32_t {
    $result = PyInt_FromLong((long)$1);
}


%typemap(in) string {
    if (PyString_Check($input)) {
        $1 = std::string(PyString_AsString($input),PyString_Size($input));
    } else {
    SWIG_exception(SWIG_TypeError, “string expected”);
    }
}

%typemap(in) const string & (std::string temp) {
    if (PyString_Check($input)) {
        temp = std::string(PyString_AsString($input),PyString_Size($input));
        $1 = &temp;
    } else {
        SWIG_exception(SWIG_TypeError, “string expected”);
    }
}

%typemap(out) string {
    $result = PyString_FromStringAndSize($1.data(),$1.size());
}

%typemap(out) const string & {
    $result = PyString_FromStringAndSize($1->data(),$1->size());
}




%{
#include "censorwords.h"
%}


%include "censorwords.h"


